package ca.polymtl.rubikcube.CubeActivity.model;

import ca.polymtl.rubikcube.CubeActivity.model.Side;
import ca.polymtl.rubikcube.CubeActivity.model.Rubik.RotationDirection;

public class CubeletTransitions {
	
	public Side sides[] = new Side[4];
	
	static CubeletTransitions getTransitions(Side side, RotationDirection way) {
		
		int a, b, c, d;
		CubeletTransitions t = new CubeletTransitions();
		
		if (side.ordinal() <= 2 && way == RotationDirection.CCW ||
				side.ordinal() >= 3 && way == RotationDirection.CW) {
			a = 0;
			b = 1;
			c = 2;
			d = 3;
		} else {
			a = 3;
			b = 2;
			c = 1;
			d = 0;
		}
		
		switch (side) {
		case FRONT:
		case BACK:
		case MIDDLE_FB:
			t.sides[a] = Side.RIGHT;
			t.sides[b] = Side.DOWN;
			t.sides[c] = Side.LEFT;
			t.sides[d] = Side.UP;
			break;

		case UP:
		case DOWN:
		case MIDDLE_UD:
			t.sides[a] = Side.RIGHT;
			t.sides[b] = Side.FRONT;
			t.sides[c] = Side.LEFT;
			t.sides[d] = Side.BACK;
			break;

		case RIGHT:
		case LEFT:
		case MIDDLE_RL:
			t.sides[a] = Side.BACK;
			t.sides[b] = Side.DOWN;
			t.sides[c] = Side.FRONT;
			t.sides[d] = Side.UP;
			break;

		}
		return t;
	}
}
